//
//  MQLeadListCell.swift
//  MQCRM
//
//  Created by 许博 on 2017/4/25.
//  Copyright © 2017年 mechat. All rights reserved.
//

import UIKit

class MQLeadListCell: UITableViewCell {
    
    var viewModel:MQLeadListViewModel? {
        didSet{
            nameLabel.text = viewModel?.listModel?.Name
            detailLabel.text = viewModel?.listModel?.Account
            timeLabel.text = viewModel?.dateString
        }
    }

    override func awakeFromNib() {
        super.awakeFromNib()
     
    }

    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setupUI(){
        selectionStyle = .none
//        accessoryType = .disclosureIndicator
        contentView.addSubview(nameLabel)
        contentView.addSubview(detailLabel)
        contentView.addSubview(timeLabel)
    }
    
    
    
    override func layoutSubviews() {
        
        let cellW = CGFloat(bounds.width)
        super.layoutSubviews()
        nameLabel.frame = CGRect(x: KCommonCellPadding, y: 12 , width: 1/2*cellW, height: 20)
        detailLabel.frame = CGRect(x: KCommonCellPadding , y: nameLabel.frame.maxY + 2 , width: cellW - 60, height: 20)
        timeLabel.frame = CGRect(x: cellW - KCommonCellPadding - 150, y: 12, width: 150, height: 20)
        
        
    }
    
    fileprivate lazy var nameLabel:UILabel = {
        let label = UILabel()
        label.font = UIFont.systemFont(ofSize: 16)
        label.textColor = UIColor.charcoalGrey
        return label
    }()
    
    fileprivate lazy var detailLabel:UILabel = {
        let label = UILabel()
        label.font = UIFont.systemFont(ofSize: 13)
        label.textColor = UIColor.steelGrey
        return label
    }()
    
    fileprivate lazy var timeLabel:UILabel = {
        let label = UILabel()
        label.font = UIFont.systemFont(ofSize: 13)
        label.textAlignment = .right
        label.textColor = UIColor.steelGrey
        return label
    }()
}
